home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / CREDITS / BITMAP.INC < prev    next >
Encoding:
Text File  |  1994-02-13  |  3.7 KB  |  95 lines

  1. ;----------------------------------------------------------------------
  2. ;
  3. ; void add_bitmap(X, Y, ScrnOffs, Width, Height, char far *Bitmap)
  4. ;
  5. ;----------------------------------------------------------------------
  6. proc        add_bitmap
  7. arg         X:word,Y:word,ScrnOffs:word,Width:word,Height:word,Bitmap:dword
  8.             push bp                         ;\ initialize our stack frame
  9.             mov bp,sp                       ;/
  10.             push ds si
  11.             cld                             ;clear the direction flag
  12.             mov es,[VGASeg]                 ;\
  13.             mov ax,[Y]                      ; \
  14.             mul [ModeXLogWidth]             ;  \
  15.             mov di,[ScrnOffs]               ;   \ ES:DI ==> video segment position
  16.             add di,ax                       ;   /
  17.             mov cx,[X]                      ;  /
  18.             shr cx,2                        ; /
  19.             add di,cx                       ;/
  20.             lds si,[Bitmap]                 ;DS:SI ==> Bitmap data
  21.             mov [@@Plane],0                 ;Set plane counter to 0
  22.             mov [@@Source],si               ;\ save our pointers
  23.             mov [@@Target],di               ;/
  24. @@PlaneLoop:mov cl,[@@Plane]                ;\
  25.             mov ah,1                        ; \ send out plane to write to
  26.             shl ah,cl                       ; /
  27.             @Set_Write_Plane                ;/
  28.             mov ah,[@@Plane]                ;\ send out the plane to read from
  29.             @Set_Read_Plane                 ;/
  30.  
  31.             mov si,[@@Source]
  32.             mov di,[@@Target]
  33.  
  34.             mov dx,[Height]                 ;DX = number of rows in image
  35. @@RowLoop:  mov cx,[Width]                  ;CX = number of columns in image
  36.             dec cx                          ;     minus one
  37.             mov [@@TempRow],di
  38. @@ColLoop:  mov al,[byte ds:si]             ;\
  39.             add si,4                        ; \
  40.             add [byte es:di],al             ;  \ write the pixel
  41.             jnc @@NoCarry                   ;  /
  42.             mov [byte es:di],0FFh           ; /
  43. @@NoCarry:  inc di                          ;/
  44.             sub cx,4                        ;\ do the next column
  45.             jnc @@ColLoop                   ;/
  46.             mov di,[@@TempRow]
  47.             add di,[ModeXLogWidth]
  48.             dec dx                          ;\ do the next row
  49.             jnz @@RowLoop                   ;/
  50.             inc [@@Source]                  ;\
  51.             inc [@@Plane]                   ; \ do the next plane
  52.             cmp [@@Plane],4                 ; /
  53.             jnz @@PlaneLoop                 ;/
  54.  
  55.             pop si ds
  56.             pop bp                          ;deinitialize the stack frame
  57.             ret                             ;return
  58. @@Plane     db ?
  59. @@Source    dw ?
  60. @@Target    dw ?
  61. @@TempRow   dw ?
  62. endp        add_bitmap
  63.  
  64. ;----------------------------------------------------------------------
  65. ;
  66. ;           FS:SI ==> normal linear bitmap (must be size of full screen)
  67. ;           BX = page offset
  68. ;
  69. ;----------------------------------------------------------------------
  70. proc        DisplayBitmap
  71.             mov es,[VGASeg]
  72.             cld
  73.             mov bp,0        ;start on plane 0
  74. @@PlaneLoop:mov ah,0001b
  75.             mov cx,bp
  76.             shl ah,cl
  77.             @Set_Write_Plane
  78.             mov di,bx
  79.             mov cx,PageSize
  80.             push si
  81. @@ColLoop:  mov al,[byte fs:si]
  82.             mov [byte es:di],al
  83.             inc di
  84.             add si,4
  85.             dec cx
  86.             jnz @@ColLoop
  87.             pop si
  88.             inc si
  89.             inc bp
  90.             cmp bp,4
  91.             jb @@PlaneLoop
  92.  
  93.             ret
  94. endp        DisplayBitmap
  95.